package com.itheima.utils;

import org.springframework.util.StringUtils;

import java.util.Arrays;
import java.util.List;

/**
 * <h1>XSS去除特殊标签工具类</h1>
 *
 * @author <a href="11n_yd2h5e1jx8@dingtalk.com">叶世铭</a>
 * @since 2023/2/21
 */
public class XssUtil {

    public final static List<String> blackList = Arrays.asList("script", "alert");

    public static String clean(String value) {
        if (StringUtils.isEmpty(value)) {
            return value;
        }
        for (int i = 0; i < blackList.size(); i++) {
            value = value.replaceAll(blackList.get(i), "");
        }
        return value;
    }
}
